package
{
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	import gs.easing.*;
	
	import sangpil.temp.EasingSet;
	import sangpil.temp.event.EasingSetEvent;
	
	[SWF(width = 1024, height = 700, frameRate = 30, backgroundColor = '0x333333')]
	public class TestEasingSet extends Sprite
	{
		private var listArr:Array = [];
		private var setArr:Array = [];
		private var totalHeight:Number = 0;
		private var codePad:TextField = new TextField();
		
		public function TestEasingSet()
		{
			super();
			this.makeFncList();
			
			var saveNextLine:uint = 18;
			for(var i:int = 0; i < listArr.length; i++)
			{
				this.setArr[i] = new EasingSet(this.listArr[i].label, this.listArr[i].data);
				this.addChild(this.setArr[i]);
				this.setArr[i].addEventListener(EasingSetEvent.CHANGE_ITEM, showCode); 

				if(i > this.listArr.length/2)
				{
					this.setArr[i].y = (i-saveNextLine) * (this.setArr[i].height)+15;
					this.setArr[i].x = 500;
				}else{
					this.setArr[i].y = i * (this.setArr[i].height)+15;
					totalHeight = this.setArr[i].y + 20;
				}

			}
			//강제 발
			//this.setArr[10].trigger();
			//trace(this.totalHeight);

			this.showMathCode();
			
		}
		private var format1:TextFormat = new TextFormat();
		
		private function showMathCode():void
		{
			this.codePad.x = 15;
			this.codePad.y = this.totalHeight + 20;
			this.codePad.height = 250;
			this.codePad.width = 950;
			this.addChild(this.codePad);
			
			this.codePad.border = false;
			this.codePad.borderColor = 0x666666;
			this.codePad.text = 'Motion Method ver 1.0';
			this.codePad.textColor = 0xffffff;
			
			this.changeFont();
			
		}
		
		private function changeFont():void
		{
			format1.font="Arial";
		    format1.size=12;
			this.codePad.setTextFormat(format1);
		}
		
		private function showCode(e:EasingSetEvent):void
		{
			trace(e.codeTxt);
			this.codePad.text = e.codeTxt;
			changeFont();
		}
		
		private function makeFncList():void
		{
			listArr.push({label:"Regular.easeOut", data:null});
			listArr.push({label:"Back.easeOut", data:Back.easeOut});
			listArr.push({label:"Back.easeIn", data:Back.easeIn});
			listArr.push({label:"Back.easeInOut", data:Back.easeInOut});
			listArr.push({label:"Bounce.easeOut", data:Bounce.easeOut});
			listArr.push({label:"Bounce.easeIn", data:Bounce.easeIn});
			listArr.push({label:"Bounce.easeInOut", data:Bounce.easeInOut});
			listArr.push({label:"Circ.easeOut", data:Circ.easeOut});
			listArr.push({label:"Circ.easeIn", data:Circ.easeIn});
			listArr.push({label:"Circ.easeInOut", data:Circ.easeInOut});
			listArr.push({label:"Cubic.easeOut", data:Cubic.easeOut});
			listArr.push({label:"Cubic.easeIn", data:Cubic.easeIn});
			listArr.push({label:"Cubic.easeInOut", data:Cubic.easeInOut});
			listArr.push({label:"Elastic.easeOut", data:Elastic.easeOut});
			listArr.push({label:"Elastic.easeIn", data:Elastic.easeIn});
			listArr.push({label:"Elastic.easeInOut", data:Elastic.easeInOut});
			listArr.push({label:"Expo.easeOut", data:Expo.easeOut});
			listArr.push({label:"Expo.easeIn", data:Expo.easeIn});
			listArr.push({label:"Expo.easeInOut", data:Expo.easeInOut});
			listArr.push({label:"Linear.easeNone", data:Linear.easeNone});
			listArr.push({label:"Quad.easeOut", data:Quad.easeOut});
			listArr.push({label:"Quad.easeIn", data:Quad.easeIn});
			listArr.push({label:"Quad.easeInOut", data:Quad.easeInOut});
			listArr.push({label:"Quart.easeOut", data:Quart.easeOut});
			listArr.push({label:"Quart.easeIn", data:Quart.easeIn});
			listArr.push({label:"Quart.easeInOut", data:Quart.easeInOut});
			listArr.push({label:"Quint.easeOut", data:Quint.easeOut});
			listArr.push({label:"Quint.easeIn", data:Quint.easeIn});
			listArr.push({label:"Quint.easeInOut", data:Quint.easeInOut});
			listArr.push({label:"Sine.easeOut", data:Sine.easeOut});
			listArr.push({label:"Sine.easeIn", data:Sine.easeIn});
			listArr.push({label:"Sine.easeInOut", data:Sine.easeInOut});
			listArr.push({label:"Strong.easeOut", data:Strong.easeOut});
			listArr.push({label:"Strong.easeIn", data:Strong.easeIn});
			listArr.push({label:"Strong.easeInOut", data:Strong.easeInOut});
		}
	}
}